<?php

namespace App\Http\Requests;


class CaptchaRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'phone' => 'required|regex:/^1[34578]\d{9}$/|unique:users',
        ];
    }

    public function messages()
    {
        return [
            'phone.required'=>['error_code'=>'F002002','message'=>'手机号码不能为空！'],
            'phone.regex'=>['error_code'=>'F002003','message'=>'手机号码格式不正确！'],
            'phone.unique'=>['error_code'=>'F002004','message'=>'手机号码已存在！'],
        ];
    }
}
